import request from '@/utils/http'
// 获取菜单列表
export function fetchGetMenuList() {
  return request.get({
    url: '/auth/menu/list'
  })
}
// 获取角色列表
export function fetchGetRoleList(params: any) {
  return request.get({
    url: '/auth/role/list',
    params
  })
}
// 获取用户列表
export function fetchGetUserList(params: any) {
  return request.get({
    url: '/auth/admin/list',
    params
  })
}

// 添加菜单
export const addMenuApi = (data: any) => {
  return request.post({
    url: '/auth/menu/add',
    data
  })
}
// 编辑菜单
export const editMenuApi = (data: any) => {
  return request.post({
    url: '/auth/menu/edit',
    data
  })
}
// 删除菜单
export function deleteMenuApi(ids: number[]) {
  return request.post({
    url: '/auth/menu/del',
    data: { ids }
  })
}

// 添加用户
export const addUserApi = (data: any) => {
  return request.post({
    url: '/auth/admin/add',
    data
  })
}
// 编辑用户
export const editUserApi = (data: any) => {
  return request.post({
    url: '/auth/admin/edit',
    data
  })
}
//删除管理员 支持批量删除
export function deleteUserApi(ids: number[]) {
  return request.post({
    url: '/auth/admin/del',
    data: { ids }
  })
}

// 添加角色
export const addRoleApi = (data: any) => {
  return request.post({
    url: '/auth/role/add',
    data
  })
}

// 编辑角色
export const editRoleApi = (data: any) => {
  return request.post({
    url: '/auth/role/edit',
    data
  })
}
// 删除角色 支持批量删除
export function deleteRoleApi(ids: number[]) {
  return request.post({
    url: '/auth/role/del',
    data: { ids }
  })
}

// 获取日志列表
export function fetchLogList(params: any) {
  return request.get({
    url: '/admin/adminlog',
    params
  })
}
// 删除日志
export function deleteLogApi(ids: number[]) {
  return request.post({
    url: '/admin/adminlog/delete',
    data: { ids }
  })
}
